package com.lt.contract.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.lt.contract.bean.NM_CONTRACT_2019;
import com.lt.contract.service.NM_CONTRACT_2019Service;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@Slf4j
@RequestMapping(value = "/contract2019")
public class NMContract2019Controller {
    @Autowired
    NM_CONTRACT_2019Service nmContract2019Service;

    /**
     * 获取  2019年合同上传数据
     * @param params
     * @return
     */
    @CrossOrigin
    @ResponseBody
    @GetMapping("/queryContractList")
    public JSONArray queryContractList(@RequestParam String params){
        System.out.println(params);
        List<NM_CONTRACT_2019> contractList = null;
        try {
            Map<String,Object> map = JSON.parseObject(params);
            contractList = nmContract2019Service.queryContract2019List(map);
            JSONArray result = JSON.parseArray(JSON.toJSONString(contractList));
            return result;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }

    }

    /**
     * 获取  2019年合同上传数据
     * @param params
     * @return
     */
    @CrossOrigin
    @ResponseBody
    @GetMapping("/queryContractListCount")
    public Long queryContractListCount(@RequestParam String params){
        try {
            Map<String,Object> map = JSON.parseObject(params);
            Long count = nmContract2019Service.getContract2019ListCount(map);
            return count;
        }catch (Exception e){
            e.printStackTrace();
            return 0L;
        }

    }


}
